const TIMESTAMP = new Date().getTime();
const PUBLIC_FILE_NAME = `[name].${process.env.VUE_APP_TYPE}.${TIMESTAMP}`;

// ---- css配置 ----
let css = {
  loaderOption: {
    sass: {
      data: `@import "@/common/scss/variable.scss";`
    }
  }
};

process.env.VUE_APP_TYPE != "development" 
  ? (css.extract = {
    filename: `${PUBLIC_FILE_NAME}.css`,
    chunkFilename: `${PUBLIC_FILE_NAME}.css`
  }) : null;

module.exports = {
  css,
  
  devServer: {
    port: 3306,
    open: false,
    disableHostCheck: true,
    proxy: {
      "/api": {
        target: process.env.VUE_APP_API_URL,
        changeOrigin: true,
        pathRewrite: {
          "^/api": "/"
        }
      }
    }
  },

  configureWebpack: {
    output: {
      filename: `${PUBLIC_FILE_NAME}.js`,
      chunkFilename: `${PUBLIC_FILE_NAME}.js`
    }
  },

  chainWebpack (config) {
    // alias
    config.resolve.alias.set('@', resolve('src'))
  },

  publicPath: "vueH5/mobile"
}